package com.example.multidatasource.service.impl;

import com.example.multidatasource.annotation.MultiDataSource;
import com.example.multidatasource.dao.BookDao;
import com.example.multidatasource.domain.Book;
import com.example.multidatasource.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookDao bookDao;

    @Override
    public List<Book> findAllByPrimary() {
        return bookDao.findAllByPrimary();
    }

    @MultiDataSource(dbName = "secondry")
    @Override
    public List<Book> findAllBySecondry() {
        return bookDao.findAllBySecondry();
    }

    @MultiDataSource(dbName = "thirdry")
    @Override
    public List<Book> findAllByThirdry() {
        return bookDao.findAllByThirdry();
    }
}
